package org.example.common;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

@AllArgsConstructor
@Getter
public enum ErrorEnum {

    e_0000(ErrorConstants.SUCCESS, "ok"),
    e_0001(ErrorConstants.ILLEGAL_ARGUMENT, "illegal argument"),
    e_0012(ErrorConstants.SYSTEM_BUSY, "system busy, please wait a minute"),
    e_9999(ErrorConstants.UNKNOWN_ERROR, "unknown err");

    private final String code;
    private final String msg;

    public static ErrorEnum parse(String code) {
        for (ErrorEnum value : values()) {
            if (Objects.equals(value.code, code)) {
                return value;
            }
        }
        return null;
    }

}
